<?php
/**
 * A unique identifier is defined to store the options in the database and reference them from the theme.
 * By default it uses the theme name, in lowercase and without spaces, but this can be changed if needed.
 * If the identifier changes, it'll appear as if the options have been reset.
 *
*/
function optionsframework_option_name() {

	// 从样式表获取主题名称
	$themename = wp_get_theme();
	$themename = preg_replace("/\W/", "_", strtolower($themename) );

	$optionsframework_settings = get_option( 'optionsframework' );
	$optionsframework_settings['id'] = $themename;
	update_option( 'optionsframework', $optionsframework_settings );
}

/**
 * Defines an array of options that will be used to generate the settings page and be saved in the database.
 * When creating the 'id' fields, make sure to use all lowercase and no spaces.
 *
 * If you are making your theme translatable, you should replace 'options_framework_theme'
 * with the actual text domain for your theme.  请阅读:
 * http://codex.wordpress.org/Function_Reference/load_theme_textdomain
 *
*/
function optionsframework_options() {
/*
	// 测试数据
	$test_array = array(
		'one' => __('1', 'options_framework_theme'),
		'two' => __('2', 'options_framework_theme'),
		'three' => __('3', 'options_framework_theme'),
		'four' => __('4', 'options_framework_theme'),
		'five' => __('5', 'options_framework_theme'),
		'six' => __('6', 'options_framework_theme'),
		'seven' => __('7', 'options_framework_theme')
	);

	// 复选框数组
	$multicheck_array = array(
		'one' => __('法国吐司', 'options_framework_theme'),
		'two' => __('薄煎饼', 'options_framework_theme'),
		'three' => __('煎蛋', 'options_framework_theme'),
		'four' => __('绉绸', 'options_framework_theme'),
		'five' => __('感化饼干', 'options_framework_theme')
	);

	// 复选框默认值
	$multicheck_defaults = array(
		'one' => '1',
		'five' => '1'
	);

	// 背景默认值
	$background_defaults = array(
		'color' => '',
		'image' => '',
		'repeat' => 'repeat',
		'position' => 'top center',
		'attachment'=>'scroll' );

	// 版式默认值
	$typography_defaults = array(
		'size' => '15px',
		'face' => 'georgia',
		'style' => 'bold',
		'color' => '#bada55' );
		
	// 版式设置选项
	$typography_options = array(
		'sizes' => array( '6','12','14','16','20' ),
		'faces' => array( 'Helvetica Neue' => 'Helvetica Neue','Arial' => 'Arial' ),
		'styles' => array( 'normal' => '普通','bold' => '粗体' ),
		'color' => false
	);

	// 将所有分类（categories）加入数组
	$options_categories = array();
	$options_categories_obj = get_categories();
	foreach ($options_categories_obj as $category) {
		$options_categories[$category->cat_ID] = $category->cat_name;
	}
	
	// 将所有标签（tags）加入数组
	$options_tags = array();
	$options_tags_obj = get_tags();
	foreach ( $options_tags_obj as $tag ) {
		$options_tags[$tag->term_id] = $tag->name;
	}


	// 将所有页面（pages）加入数组
	$options_pages = array();
	$options_pages_obj = get_pages('sort_column=post_parent,menu_order');
	$options_pages[''] = 'Select a page:';
	foreach ($options_pages_obj as $page) {
		$options_pages[$page->ID] = $page->post_title;
	}

	// 如果使用图片单选按钮, define a directory path
	$imagepath =  get_template_directory_uri() . '/images/';

	$options = array();

	$options[] = array(
		'name' => __('基本设置', 'options_framework_theme'),
		'type' => 'heading');

	$options[] = array(
		'name' => __('窄文本框', 'options_framework_theme'),
		'desc' => __('窄文本框输入字段。', 'options_framework_theme'),
		'id' => 'example_text_mini',
		'std' => '默认',
		'class' => 'mini',
		'type' => 'text');

	$options[] = array(
		'name' => __('文本框', 'options_framework_theme'),
		'desc' => __('文本框输入字段。', 'options_framework_theme'),
		'id' => 'example_text',
		'std' => '默认值',
		'type' => 'text');

	$options[] = array(
		'name' => __('文本域', 'options_framework_theme'),
		'desc' => __('文本域说明', 'options_framework_theme'),
		'id' => 'example_textarea',
		'std' => '默认文本',
		'type' => 'textarea');

	$options[] = array(
		'name' => __('窄下拉列表', 'options_framework_theme'),
		'desc' => __('一个窄下拉列表', 'options_framework_theme'),
		'id' => 'example_select',
		'std' => 'three',
		'type' => 'select',
		'class' => 'mini', //mini, tiny, small
		'options' => $test_array);

	$options[] = array(
		'name' => __('宽下拉列表', 'options_framework_theme'),
		'desc' => __('一个宽下拉列表', 'options_framework_theme'),
		'id' => 'example_select_wide',
		'std' => 'two',
		'type' => 'select',
		'options' => $test_array);

	if ( $options_categories ) {
	$options[] = array(
		'name' => __('选择分类', 'options_framework_theme'),
		'desc' => __('通过cat_ID和cat_name选择categories数组', 'options_framework_theme'),
		'id' => 'example_select_categories',
		'type' => 'select',
		'options' => $options_categories);
	}
	
	if ( $options_tags ) {
	$options[] = array(
		'name' => __('选择标签', 'options_check'),
		'desc' => __('通过trem_id和term_name选择tags数组', 'options_check'),
		'id' => 'example_select_tags',
		'type' => 'select',
		'options' => $options_tags);
	}

	$options[] = array(
		'name' => __('选择页面', 'options_framework_theme'),
		'desc' => __('通过ID和post_title选择pages', 'options_framework_theme'),
		'id' => 'example_select_pages',
		'type' => 'select',
		'options' => $options_pages);

	$options[] = array(
		'name' => __('单选框（one）', 'options_framework_theme'),
		'desc' => __('单选按钮选中时值为“one”', 'options_framework_theme'),
		'id' => 'example_radio',
		'std' => 'one',
		'type' => 'radio',
		'options' => $test_array);

	$options[] = array(
		'name' => __('示例信息', 'options_framework_theme'),
		'desc' => __('这是一条示例信息，你可以在设置面板中加入它', 'options_framework_theme'),
		'type' => 'info');

	$options[] = array(
		'name' => __('复选框', 'options_framework_theme'),
		'desc' => __('复选框示例，默认为true', 'options_framework_theme'),
		'id' => 'example_checkbox',
		'std' => '1',
		'type' => 'checkbox');

	$options[] = array(
		'name' => __('高级设置', 'options_framework_theme'),
		'type' => 'heading');

	$options[] = array(
		'name' => __('单击显示隐藏的文本框', 'options_framework_theme'),
		'desc' => __('单击这里看发生了什么', 'options_framework_theme'),
		'id' => 'example_showhidden',
		'type' => 'checkbox');
		
	$options[] = array(
		'name' => __('隐藏文本框', 'options_framework_theme'),
		'desc' => __('这是一个隐藏的文本框，选中复选框后显示', 'options_framework_theme'),
		'id' => 'example_text_hidden',
		'std' => '你好',
		'class' => 'hidden',
		'type' => 'text');

	$options[] = array(
		'name' => __('上传测试', 'options_framework_theme'),
		'desc' => __('预览图像将以全尺寸上传。', 'options_framework_theme'),
		'id' => 'example_uploader',
		'type' => 'upload');

	$options[] = array(
		'name' => "图片单选按钮",
		'desc' => "",
		'id' => "example_images",
		'std' => "2c-l-fixed",
		'type' => "images",
		'options' => array(
			'1col-fixed' => $imagepath . '1col.png',
			'2c-l-fixed' => $imagepath . '2cl.png',
			'2c-r-fixed' => $imagepath . '2cr.png')
	);

	$options[] = array(
		'name' =>  __('背景示例', 'options_framework_theme'),
		'desc' => __('修改背景CSS', 'options_framework_theme'),
		'id' => 'example_background',
		'std' => $background_defaults,
		'type' => 'background' );

	$options[] = array(
		'name' => __('复选框', 'options_framework_theme'),
		'desc' => __('复选框说明', 'options_framework_theme'),
		'id' => 'example_multicheck',
		'std' => $multicheck_defaults, // These items get checked by default
		'type' => 'multicheck',
		'options' => $multicheck_array);

	$options[] = array(
		'name' => __('拾色器', 'options_framework_theme'),
		'desc' => __('默认未选择颜色', 'options_framework_theme'),
		'id' => 'example_colorpicker',
		'std' => '',
		'type' => 'color' );
		
	$options[] = array( 'name' => __('版式', 'options_framework_theme'),
		'desc' => __('版式示例', 'options_framework_theme'),
		'id' => "example_typography",
		'std' => $typography_defaults,
		'type' => 'typography' );
		
	$options[] = array(
		'name' => __('自定义版式', 'options_framework_theme'),
		'desc' => __('自定义版式设置', 'options_framework_theme'),
		'id' => "custom_typography",
		'std' => $typography_defaults,
		'type' => 'typography',
		'options' => $typography_options );

	$options[] = array(
		'name' => __('文本编辑器', 'options_framework_theme'),
		'type' => 'heading' );

	**
	 * For $settings options see:
	 * http://codex.wordpress.org/Function_Reference/wp_editor
	 *
	 * 'media_buttons' are not supported as there is no post to attach items to
	 * 'textarea_name' is set by the 'id' you choose
	 

	$wp_editor_settings = array(
		'wpautop' => true, // 默认
		'textarea_rows' => 5,
		'tinymce' => array( 'plugins' => 'wordpress' )
	);
	
	$options[] = array(
		'name' => __('默认文本编辑器', 'options_framework_theme'),
		'desc' => sprintf( __( '您可以设置编辑器，更多关于wp_editor的说明请阅读<a href="%1$s" target="_blank">the WordPress codex</a>', 'options_framework_theme' ), 'http://codex.wordpress.org/Function_Reference/wp_editor' ),
		'id' => 'example_editor',
		'type' => 'editor',
		'settings' => $wp_editor_settings );
	*/
	//seo设置
	$options[] = array(
		'name' => __('seo设置', 'ist'),
		'type' => 'heading' );
	$options[] = array(
		'name' => __('Description', 'ist'),
		'desc' => __('description', 'ist'),
		'id' => "mydes",
		'std' => '',
		'type' => 'textarea' );
	$options[] = array(
		'name' => __('keywords', 'ist'),
		'desc' => __('keywords', 'ist'),
		'id' => "mykey",
		'std' => '',
		'type' => 'textarea' );
	$options[] = array(
		'name' => __('自定义代码','ist'),
		'desc' => __('css','ist'),
		'id' => 'csscode',
		'std' => '',
		'type' => 'textarea');
	$options[] = array(
		'name' => __('头部代码','ist'),
		'desc' => __('网站验证，需要写script','ist'),
		'id' => 'headcode',
		'std' => '',
		'type' => 'textarea');
	$options[] = array(
		'name' => __('备案代码','ist'),
		'desc' => __('备案','ist'),
		'id' => 'isticp',
		'std' => '萌ICP-802',
		'type' => 'text');
	//社交
	$options[] = array(
		'name' => __('社交设置', 'ist'),
		'type' => 'heading' );
	$options[] = array(
		'name' => __('Weibo', 'ist'),
		'desc' => __('没事多刷刷微博', 'ist'),
		'id' => "caibao",
		'std' => 'http://weibo.com/caibaodoge/',
		'type' => 'text' );
	$options[] = array(
		'name' => __('Twitter', 'ist'),
		'desc' => __('有必要关注一下大牛的推特啊', 'ist'),
		'id' => "caibao_t",
		'std' => '',
		'type' => 'text' );
	$options[] = array(
		'name' => __('RSS','ist'),
		'desc' => __('RSS','ist'),
		'id' => 'caibao_r',
		'std' => '',
		'type' => 'text');
	$options[] = array(
		'name' => __('mail','ist'),
		'desc' => __('邮箱 格式：mailto:root ysicing net','ist'),
		'id' => 'caibao_e',
		'std' => '',
		'type' => 'text');
	$options[] = array(
		'name' => __('Github','ist'),
		'desc' => __('项目托管','ist'),
		'id' => 'caibao_g',
		'std' => '',
		'type' => 'text');
	$options[] = array(
		'name' => __('QQ','ist'),
		'desc' => __('qq/微信','ist'),
		'id' => 'caibao_q',
		'std' => '188075810',
		'type' => 'text');
	$options[] = array(
		'name' => __('IRC','ist'),
		'desc' => __('irc','ist'),
		'id' => 'caibao_i',
		'std' => '',
		'type' => 'text');
	$options[] = array(
		'name' => __('功能设置', 'ist'),
		'type' => 'heading' );
	$options[] = array(
        'name' => __('缩略图设置', 'ist'),
        'desc' => __(' 是否使用Timthumb插件自动裁减？默认开启', 'ist'),
        'id' => 'ist_tim_s',
        'std' => true,
        'type' => 'checkbox'
    );
    $options[] = array(
        'name' => __('技术笔记ID设置','ist'),
        'desc' => __(' 默认为2', 'ist'),
        'id' => 'ist_js',
        'std' => '2',
        'type' => 'text');
    $options[] = array(
        'name' => __('技术笔记数目设置', 'ist'),
        'desc' => __(' 默认为10', 'ist'),
        'id' => 'ist_js_num',
        'std' => '10',
        'type' => 'text');
    $options[] = array(
        'name' => __('Writeup设置', 'ist'),
        'desc' => __(' 默认为20', 'ist'),
        'id' => 'ist_ctf',
        'std' => '20',
        'type' => 'text');
    $options[] = array(
        'name' => __('Writeup数目设置', 'ist'),
        'desc' =>__(' 默认为10', 'ist'),
        'id' => 'ist_ctf_num',
        'std' => '10',
        'type' => 'text');
    $options[] = array(
        'name' => __('Python设置', 'ist'),
        'desc' => __(' 默认为7', 'ist'),
        'id' => 'ist_py',
        'std' => '7',
        'type' => 'text');
    $options[] = array(
        'name' => __('Py数目设置', 'ist'),
        'desc' => __(' 默认为10', 'ist'),
        'id' => 'ist_py_num',
        'std' => '10',
        'type' => 'text');
    $options[] = array(
        'name' => __('老司机设置', 'ist'),
        'desc' => __(' 默认为5', 'ist'),
        'id' => 'ist_av',
        'std' => '5',
        'type' => 'text');
    $options[] = array(
        'name' => __('老司机数目设置', 'ist'),
        'desc' => __(' 默认为10',  'ist'),
        'id' => 'ist_av_num',
        'std' => '10',
        'type' => 'text');
    $options[] = array(
        'name' => __('广告位', 'ist') ,
        'type' => 'heading'
    );
    $options[] = array( //yes
        'name' => __('文章页正文结尾文字广告', 'ist') ,
        'id' => 'ads_post_footer_s',
        'std' => true,
        'desc' => ' 显示',
        'type' => 'checkbox'
    );
    $options[] = array( //yes
        'desc' => '标题',
        'id' => 'ads_post_footer_title',
        'std' => '吾爱笔记 | 行走在安全的网络世界',
        'type' => 'text'
    );
    $options[] = array( //yes
        'desc' => '链接（直接填写地址，别忘了http://）',
        'id' => 'ads_post_footer_link',
        'std' => '',
        'type' => 'text'
    );
    $options[] = array( //yes
        'id' => 'ads_post_footer_link_blank',
        'type' => 'checkbox',
        'std'=>false,
        'desc' => __('开启', 'ist') . ' (' . __('新窗口打开链接，如果链接没填写请不要开启', 'ist') . ')'
    );
    $options[] = array(  
        'name' => __('AD1首页列表最前', 'ist') ,
        'id' => 'ads_01_s',
        'std' => true,
        'desc' => __('开启', 'ist') ,
        'type' => 'checkbox'
    );
    $options[] = array( 
        'desc' => __('如首页幻灯开启则在幻灯与列表的中间，最大宽度830px，默认居中', 'ist') ,
        'id' => 'ads_01',
        'type' => 'textarea'
    );
    $options[] = array(
        'name' => __('AD2首页及分类列表页分页下', 'ist') ,
        'id' => 'ads_02_s',
        'std' => true,
        'desc' => __('开启', 'ist') ,
        'type' => 'checkbox'
    );
    $options[] = array(
        'desc' => __('位于（首页、各类归档页、分类页）的分页标签下，最大宽度830px，默认居中', 'ist') ,
        'id' => 'ads_02',
        'type' => 'textarea'
    );
    $options[] = array( //yes
        'name' => __('AD3文章页及页面正文上', 'ist') ,
        'id' => 'ads_03_s',

        'std' => true,
        'desc' => __('开启', 'ist') ,
        'type' => 'checkbox'
    );
    $options[] = array( //yes
        'desc' => __('位于文章页及页面（默认模版）正文前，最大宽度830px，默认居中', 'ist') ,
        'id' => 'ads_03',
        'type' => 'textarea'
    );
    $options[] = array( //yes
        'name' => __('AD4文章页分页前，以及页面作者信息后', 'ist') ,
        'id' => 'ads_04_s',
        'std' => true,
        'desc' => __('开启', 'ist') ,
        'type' => 'checkbox'
    );
    $options[] = array( //yes
        'desc' => __('位于文章页分页前，以及页面作者信息后，最大宽度830px，默认居中', 'ist') ,
        'id' => 'ads_04',
        'type' => 'textarea'
    );
    $options[] = array(//yes
        'name' => __('AD5文章页及页面评论下', 'ist') ,
        'id' => 'ads_05_s',
        'std'=>false,
        'desc' => __('开启', 'ist') ,
        'type' => 'checkbox'
    );
    $options[] = array(//yes
        'desc' => __('位于文章页及页面（默认模版）评论列表下，最大宽度830px，默认居中', 'ist') ,
        'id' => 'ads_05',
        'type' => 'textarea'
    );
	$options[] = array( //yes
        'name' => __('PHONE-AD1 手机模式', 'ist') ,
        'id' => 'adm_01_s',
        'std'=>false,
        'desc' => __('开启', 'ist') ,
        'type' => 'checkbox'
    );
    $options[] = array( //yes
        'desc' => __('手机模式下展示的广告，此广告位于：全站列表头部，文章页标题下', 'ist') ,
        'id' => 'adm_01',
        'type' => 'textarea'
    );
	$options[] = array(
        'name' => __('PHONE-AD2 手机模式', 'ist') ,
        'id' => 'adm_02_s',
        'std'=>false,
        'desc' => __('开启', 'ist') ,
        'type' => 'checkbox'
    );
    $options[] = array(
        'desc' => __('手机模式下展示的广告，此广告位于：全站列表分页前，文章页评论前', 'ist') ,
        'id' => 'adm_02',
        'type' => 'textarea'
    );
	$options[] = array(  
        'name' => __('PHONE-AD3 手机模式', 'ist') ,
        'id' => 'adm_03_s',
        'std'=>false,
        'desc' => __('开启', 'ist') ,
        'type' => 'checkbox'
    );
    $options[] = array( 
        'desc' => __('手机模式下展示的广告，此广告位于footer文件里，用于添加百度隐藏悬浮、图+等代码', 'ist') ,
        'id' => 'adm_03',
        'type' => 'textarea'
    );
	return $options;
}